﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using XNAGuiLib.Core.Utilities;

namespace XNAGuiLib.Core.Resources
{
    public class ResourceManager
    {
        #region Private Field - _game
        // private field for a game instance (needed to get a usable IServiceProvider object)
        private Game _game;
        #endregion



        #region Constructor - ResourceManager(Game game)
        /// <summary>
        /// default constructor
        /// </summary>
        /// <param name="game">game instance to get the ServiceProvider from</param>
        private ResourceManager(Game game)
        {
            _game = game;
        }
        #endregion





        #region Method - Instance(Game game)
        private static ResourceManager _instance = null;
        /// <summary>
        /// gets the RManager instance
        /// </summary>
        public static ResourceManager Instance(Game game)
        {
            if (_instance == null)
                _instance = new ResourceManager(game);

            return _instance;
        }
        #endregion

        #region Method - Instance(Game game, RManagerType type)
        /// <summary>
        /// gets the RManager instance
        /// </summary>
        public static ResourceContentManager Instance(Game game, Enums.RCM type)
        {
            switch (type)
            {
                // --------------------------------------------
                // case: FontManager type to return
                case Enums.RCM.Font:
                    return Instance(game).FontManager;
                // --------------------------------------------
                // case: StyleDefaultManager type to return
                case Enums.RCM.Vista_Graphit:
                    return Instance(game).Vista_Graphit;
                // default RCM
                default:
                    return Instance(game).Vista_Graphit;
            }
        }
        #endregion


        #region Static Field - FontManager
        private ResourceContentManager _fontManager = null;
        /// <summary>
        /// gets the default FontManager object for the XNAGuiLib
        /// </summary>
        public ResourceContentManager FontManager
        {
            get
            {
                if (_fontManager == null)
                    _fontManager = new ResourceContentManager(_game.Content.ServiceProvider, global::XNAGuiLib.Properties.Fonts.ResourceManager);

                return _fontManager;
            }
        }
        #endregion


        #region Static Field - Vista_Graphit
        private ResourceContentManager _vista_graphit = null;
        /// <summary>
        /// gets the default vista graphit object for the XNAGuiLib
        /// </summary>
        public ResourceContentManager Vista_Graphit
        {
            get
            {
                if (_vista_graphit == null)
                    _vista_graphit = new ResourceContentManager(_game.Content.ServiceProvider, global::XNAGuiLib.Properties.Vista_Graphit.ResourceManager);

                return _vista_graphit;
            }
        }
        #endregion
    }
}